package com.library.library.Interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @Auther: 杜習田
 * @Date: 2019/12/27 09:43
 * @Description: 注册拦截器
 */
@Configuration
public class InterceptorChainLoader extends WebMvcConfigurationSupport {

    @Bean
    public IsLoginInterceptorImpl isLoginInterceptor(){
        return new IsLoginInterceptorImpl();
    }

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {

        // 有多个拦截器可以多次add组成拦截器链
        registry.addInterceptor(isLoginInterceptor()).addPathPatterns("/**").excludePathPatterns("/user/login", "/user/register","/image/**");
        super.addInterceptors(registry);
    }
}
